package com.zisuyi.uilibrary.module.dialog.redeem

import android.graphics.Color
import android.view.View
import com.weilele.mvvm.utils.activity.SpanBean
import com.weilele.mvvm.utils.activity.textFrom
import com.weilele.mvvm.utils.activity.textFromSpanBean
import com.weilele.mvvm.utils.insetSplitStr

import com.weilele.mvvm.utils.vLaout.VLayoutHolder
import com.zisuyi.game.sdk.net.bean.UserInfoBean
import com.zisuyi.uilibrary.databinding.RcvRedeemDialogBinding

class RedeemDialogHolder : VLayoutHolder<RedeemDialogHolder.Bean, RcvRedeemDialogBinding> {
    constructor(binding: RcvRedeemDialogBinding) : super(binding)
    constructor(itemView: View) : super(itemView)

    data class Bean(val conditionsDTO: UserInfoBean.RedeemDTO.ConditionsDTO)

    override fun bindData(data: Bean) {
        mBinding.tvName.textFrom(data.conditionsDTO.message)
        val enableCondition = data.conditionsDTO.complete.toInt() >= data.conditionsDTO.value.toInt()
        mBinding.tvProgress.textFromSpanBean(
                mutableListOf(
                        SpanBean(data.conditionsDTO.complete.toString().insetSplitStr(),
                                textColor = if (!enableCondition) Color.RED else null),
                        SpanBean("/" + data.conditionsDTO.value.toString().insetSplitStr())
                )
        )
    }
}